package com.wzq.coontroller;

import com.wzq.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wzq.Jolin
 * @company none
 * @create 2020-09-14 16:05
 */
@RestController

public class CodeController {

    @Autowired
    private CodeService codeService;

    /**
     * 创建并发送验证码给邮箱
     * @param email
     * @return
     */

    @RequestMapping("/code/create/{email}")

    public boolean create(@PathVariable String email){
        return codeService.create(email);
    }

    /**
     * 验证验证码
     * @param email
     * @param code
     * @return  校验验证码是否正确，0正确1错误2超时
     */
    @RequestMapping("/code/validate/{email}/{code}")
    public Integer validate(@PathVariable String email,@PathVariable String code){
        return codeService.validate(email,code);
    }
}
